package com.luoye.lj.platform.dao.impl;

import java.util.List;
import com.luoye.lj.platform.dao.IManageMenuDao;
import com.luoye.lj.platform.dao.mapper.IManageMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.luoye.lj.platform.pojo.dbo.ManageMenuDbo;
import com.luoye.lj.platform.pojo.dbo.ManageMenuDboSearchCondition;
import com.luoye.lj.platform.pojo.dbo.ManageMenuDboCollection;

/**
 * Created with IntelliJ IDEA.
 * User:
 * Date:
 * Time:
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class ManageMenuDaoImpl implements IManageMenuDao {
    @Autowired
    private IManageMenuMapper manageMenuMapper;

    @Override
    public int insert(ManageMenuDbo manageMenuDbo) {
        return manageMenuMapper.insert(manageMenuDbo);
    }

    @Override
    public int delete(long id) {
        return manageMenuMapper.delete(id);
    }

    @Override
    public int update(ManageMenuDbo manageMenuDbo) {
        return manageMenuMapper.update(manageMenuDbo);
    }

    @Override
    public ManageMenuDbo get(long id) {
        return manageMenuMapper.get(id);
    }

    @Override
    public ManageMenuDboCollection searchByCondition(ManageMenuDboSearchCondition manageMenuDboSearchCondition) {
        int count=manageMenuMapper.countByCondition(manageMenuDboSearchCondition);
        List<ManageMenuDbo> entityList=manageMenuMapper.searchByCondition(manageMenuDboSearchCondition);
        ManageMenuDboCollection manageMenuDboCollection=new ManageMenuDboCollection();
        manageMenuDboCollection.setTotalCount(count);
        manageMenuDboCollection.setEntityList(entityList);
        return manageMenuDboCollection;
    }

    @Override
    public List<ManageMenuDbo> deleteByCondition(ManageMenuDboSearchCondition manageMenuDboSearchCondition){
        manageMenuDboSearchCondition.setOffset(0);
        manageMenuDboSearchCondition.setMax(Integer.MAX_VALUE);
        List<ManageMenuDbo> entityList=manageMenuMapper.searchByCondition(manageMenuDboSearchCondition);
        if(manageMenuMapper.deleteByCondition(manageMenuDboSearchCondition)<=0){
            return null;
        }
        return entityList;
    }

    @Override
    public ManageMenuDbo statisticsByCondition(ManageMenuDboSearchCondition manageMenuDboSearchCondition) {
        return manageMenuMapper.statisticsByCondition(manageMenuDboSearchCondition);
    }

    @Override
    public long getMaxId() {
        return manageMenuMapper.getMaxId();
    }
}
